home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / dutil / cat.c < prev    next >
C/C++ Source or Header  |  1997-09-09  |  856b  |  53 lines

  1. /*
  2.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  3.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  4.  *    DICE-LICENSE.TXT.
  5.  */
  6.  
  7. /*
  8.  *  CAT.C
  9.  */
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13.  
  14. #include <lib/version.h>
  15.  
  16. IDENT("cat",".2");
  17. DCOPYRIGHT;
  18.  
  19. int _DiceCacheEnable = 1;
  20.  
  21. main(ac, av)
  22. int   ac;
  23. char **av;
  24. {
  25.     int   i;
  26.     char buf[256];
  27.  
  28.     Ident;        /* references so GNU-C does not complain */
  29.     DCopyright;
  30.  
  31. #ifdef AMIGA
  32.     expand_args(ac, av, &ac, &av);
  33. #endif
  34.  
  35.     for (i = 1; i < ac; ++i) {
  36.     FILE *fi = fopen(av[i], "r");
  37.     if (fi == NULL) {
  38.         fprintf(stderr, "Unable to open %s\n", av[i]);
  39.         continue;
  40.     }
  41.     while (fgets(buf, sizeof(buf), fi))
  42.         fputs(buf, stdout);
  43.     fclose(fi);
  44.     }
  45.     if (ac == 1) {
  46.     short c;
  47.     while ((c = getc(stdin)) != EOF)
  48.         putc(c, stdout);
  49.     }
  50.     return(0);
  51. }
  52.  
  53.